package com.cdut.hwadeefsc.mapper;

import com.cdut.hwadeefsc.entity.articles;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
* @author 1
* @description 针对表【articles(文章表)】的数据库操作Mapper
* @createDate 2025-09-15 15:08:59
* @Entity com.cdut.hwadeefsc.entity.articles
*/
public interface articlesMapper extends BaseMapper<articles> {
    @Insert("INSERT INTO articles(title, content, author_id, type, is_pinned, created_at, updated_at) VALUES(#{title}, #{content}, #{authorId}, #{type}, #{isPinned}, #{createdAt}, #{updatedAt})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int post(articles articles);

    @Select("SELECT * FROM articles")
    List<articles> get();

    @Select("SELECT * FROM articles WHERE id = #{id}")
    articles getById(Long id);

    @Update("UPDATE articles SET title = #{title}, content = #{content}, author_id = #{authorId}, type = #{type}, is_pinned = #{isPinned}, updated_at = #{updatedAt} WHERE id = #{id}")
    int modify(articles articles);

    @Delete("DELETE FROM articles WHERE id = #{id}")
    int delete(Long id);


}




